package Testdmo1;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Testdmo1.Date: 2024-02-25
 * Time：23:06
 */
// 两数组比较
public class J2_25 {
    public static void main(String[] args) {
        int []a={1,2,3,4,5,6,7,8,9,10};
        int []b={1,2,3,5,6,7,8,9,11};
        int sz= Arrays.compare(a,a);
        System.out.println(sz);

        Scanner in=new Scanner(System.in);
        String s=in.nextLine();
    }

}


class TreeNode {
    public char val;
    public TreeNode left;
    public TreeNode right;
    public static int i;

    public TreeNode(char val) {
        this.val=val;
    }

    public static TreeNode CreateTree(String s) {
        TreeNode root=null;
        if(s.charAt(i) != '#') {
            root=new TreeNode(s.charAt(i));
            i++;
            root.left=CreateTree(s);
            root.right=CreateTree(s);
        } else {
            i++;
        }

        return root;
    }


    public static void middleDisplay(TreeNode root) {
        if(root==null) {
            return ;
        }

        middleDisplay(root.left);
        System.out.print(root.val+" ");
        middleDisplay(root.right);
    }

}






// 注意类名必须为 Main, 不要有任何 package xxx 信息
 class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别

            while (in.hasNextLine()) {
                String s=in.nextLine();
                in.nextLine();
                TreeNode root= TreeNode.CreateTree(s);
                TreeNode.middleDisplay(root);

            }

    }
}